#include "led.h"
#include "gpio.h"

#include "fun.h"

extern int water_led_count;

void led_show(uint8_t led,uint8_t mode)
{
		HAL_GPIO_WritePin(GPIOD ,GPIO_PIN_2,GPIO_PIN_SET );
		
		if(1 == mode)
				HAL_GPIO_WritePin(GPIOC ,GPIO_PIN_8 <<(led-1) ,GPIO_PIN_RESET );
		else if(0 == mode )
				HAL_GPIO_WritePin(GPIOC ,GPIO_PIN_8 <<(led-1) ,GPIO_PIN_SET );
		
		HAL_GPIO_WritePin(GPIOD ,GPIO_PIN_2,GPIO_PIN_RESET );

}

void led_up(void)
{
		if(5 == water_led_count)
		{
				led_show (8,0);
				led_show (water_led_count,1);
		}
		else if(6 == water_led_count)
		{
				led_show (water_led_count-1,0);
				led_show (water_led_count,1);
		}
		else if(7 == water_led_count)
		{
				led_show (water_led_count-1,0);
				led_show (water_led_count,1);
		}
		else if(8 == water_led_count)
		{
				led_show (water_led_count-1,0);
				led_show (water_led_count,1);
		}
		
}

void led_down(void)
{
		if(5 == water_led_count)
		{
				led_show (5,0);
				led_show (8,1);
		}
		else if(6 == water_led_count)
		{
				led_show (8,0);
				led_show (7,1);
		}
		else if(7 == water_led_count)
		{
				led_show (7,0);
				led_show (6,1);
		}
		else if(8 == water_led_count)
		{
				led_show (6,0);
				led_show (5,1);
		}
}

void led_5_8_clear(void)
{
		led_show (5,0);
		led_show (6,0);
		led_show (7,0);
		led_show (8,0);
}
